{% extends 'xadmin/base/base.html' %}
{% load static %}

{% block title %}
  用户管理页
{% endblock %}

{% block header %}
  用户管理
{% endblock %}

{% block header-option %}
  用户管理
{% endblock %}


{% block content %}
  <div class="row">
    <div class="col-md-12 col-xs-12 col-sm-12">
      <div class="box box-primary">
        <div class="box-body">
          <table class="table table-bordered table-hover">
            <thead>
            <tr>
              <th>用户名</th>
              <th>是否能登录后台？</th>
              <th>是否是超级管理员？</th>
              <th>所属组</th>
              <th>操作</th>
            </tr>
            </thead>
            <tbody id="tbody">
            {% for one_user in users %}
              <tr data-id="{{ one_user.id }}" data-name="{{ one_user.username }}">
                <td>{{ one_user.username }}</td>
                {% if one_user.is_staff %}
                  <td>是</td>
                {% else %}
                  <td>否</td>
                {% endif %}

                {% if one_user.is_superuser %}
                  <td>是</td>
                {% else %}
                  <td>否</td>
                {% endif %}
                  <td>
                        {% if one_user.groups.count > 1 %}
                      <label for="group" style="color:green">多个组</label>
                            {% else %}
                        <label for="group" style="color:green">单身组</label>
                  {% endif %}
                      <select class="from-control" name="group_id" id="group">
                      <option value="0" style="diaplay:none">--请选择分组--</option>
                            {% for g in groups %}
                                {% if g in one_user.groups.all %}
                                     <option value="{{ g.id }}" selected>{{ g.name }}</option>
                                {% endif %}
                              {% endfor %}
                          </select>
                    </td>


{#                <td>{{ one_user.get_group_name }}</td>#}

                <td>
                  <a href="{% url 'x-admin:user-edit' one_user.id %}" class="btn btn-xs btn-warning btn-edit">编辑</a>
                  <button class="btn btn-xs btn-danger btn-del">删除</button>
                </td>
              </tr>
            {% endfor %}


            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
{% endblock %}

{% block script %}
  <script src="{% static 'xadmin/js/user/user_manage.js' %}"></script>
{% endblock %}